﻿using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;
using WebExam.Core.Repository;

namespace WebExam.DataEntities
{
    [Table(Name = "dbo.EnST")]
    public partial class EnST : Entity
    {

        private decimal _enSTNum;

        private decimal _powerNum;

        private string _enST;

        private string _optionA;

        private string _optionB;

        private string _optionC;

        private string _optionD;

        private string _enDA;

        private string _enJX;

        private EntityRef<EnPower> _EnPower;

        public EnST()
        {
            this._EnPower = default(EntityRef<EnPower>);
        }

        [Column(Storage = "_enSTNum", AutoSync = AutoSync.OnInsert, DbType = "Decimal(18,0) NOT NULL IDENTITY", IsPrimaryKey = true, IsDbGenerated = true)]
        public decimal EnSTNum
        {
            get
            {
                return this._enSTNum;
            }
            set
            {
                if ((this._enSTNum != value))
                {
                    this.SendPropertyChanging("EnSTNum");
                    this._enSTNum = value;
                    this.SendPropertyChanged("EnSTNum", value);
                }
            }
        }

        [Column(Storage = "_powerNum", DbType = "Decimal(18,0)")]
        public decimal PowerNum
        {
            get
            {
                return this._powerNum;
            }
            set
            {
                if ((this._powerNum != value))
                {
                    if (this._EnPower.HasLoadedOrAssignedValue)
                    {
                        throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
                    }
                    this.SendPropertyChanging("PowerNum");
                    this._powerNum = value;
                    this.SendPropertyChanged("PowerNum", value);
                }
            }
        }

        [Column(Storage = "_enST", DbType = "VarChar(500)")]
        public string EnTM
        {
            get
            {
                return this._enST;
            }
            set
            {
                if ((this._enST != value))
                {
                    this.SendPropertyChanging("EnTM");
                    this._enST = value;
                    this.SendPropertyChanged("EnTM", value);
                }
            }
        }

        [Column(Storage = "_optionA", DbType = "VarChar(500)")]
        public string OptionA
        {
            get
            {
                return this._optionA;
            }
            set
            {
                if ((this._optionA != value))
                {
                    this.SendPropertyChanging("OptionA");
                    this._optionA = value;
                    this.SendPropertyChanged("OptionA", value);
                }
            }
        }

        [Column(Storage = "_optionB", DbType = "VarChar(500)")]
        public string OptionB
        {
            get
            {
                return this._optionB;
            }
            set
            {
                if ((this._optionB != value))
                {
                    this.SendPropertyChanging("OptionB");
                    this._optionB = value;
                    this.SendPropertyChanged("OptionB", value);
                }
            }
        }

        [Column(Storage = "_optionC", DbType = "VarChar(500)")]
        public string OptionC
        {
            get
            {
                return this._optionC;
            }
            set
            {
                if ((this._optionC != value))
                {
                    this.SendPropertyChanging("OptionC");
                    this._optionC = value;
                    this.SendPropertyChanged("OptionC", value);
                }
            }
        }

        [Column(Storage = "_optionD", DbType = "VarChar(500)")]
        public string OptionD
        {
            get
            {
                return this._optionD;
            }
            set
            {
                if ((this._optionD != value))
                {
                    this.SendPropertyChanging("OptionD");
                    this._optionD = value;
                    this.SendPropertyChanged("OptionD", value);
                }
            }
        }

        [Column(Storage = "_enDA", DbType = "VarChar(500) NOT NULL", CanBeNull = false)]
        public string EnDA
        {
            get
            {
                return this._enDA;
            }
            set
            {
                if ((this._enDA != value))
                {
                    this.SendPropertyChanging("EnDA");
                    this._enDA = value;
                    this.SendPropertyChanged("EnDA", value);
                }
            }
        }

        [Column(Storage = "_enJX", DbType = "VarChar(1000)")]
        public string EnJX
        {
            get
            {
                return this._enJX;
            }
            set
            {
                if ((this._enJX != value))
                {
                    this.SendPropertyChanging("EnJX");
                    this._enJX = value;
                    this.SendPropertyChanged("EnJX", value);
                }
            }
        }

        [Association(Name = "EnPower_EnST", Storage = "_EnPower", ThisKey = "PowerNum", OtherKey = "PowerNum", IsForeignKey = true)]
        public EnPower EnPower
        {
            get
            {
                return this._EnPower.Entity;
            }
            set
            {
                EnPower previousValue = this._EnPower.Entity;
                if (((previousValue != value)
                            || (this._EnPower.HasLoadedOrAssignedValue == false)))
                {
                    this.SendPropertyChanging("EnPower");
                    if ((previousValue != null))
                    {
                        this._EnPower.Entity = null;
                        previousValue.EnST.Remove(this);
                    }
                    this._EnPower.Entity = value;
                    if ((value != null))
                    {
                        value.EnST.Add(this);
                        this._powerNum = value.PowerNum;
                    }
                    else
                    {
                        this._powerNum = default(decimal);
                    }
                    this.SendPropertyChanged("EnPower", value);
                }
            }
        }
    }

}
